package com.zhuiYun.project.api.classifyshops.controller;


import com.zhuiYun.project.api.classifyshops.entity.BigClassify;
import com.zhuiYun.project.api.classifyshops.entity.Classify;
import com.zhuiYun.project.api.classifyshops.entity.CommodityComment;
import com.zhuiYun.project.api.classifyshops.service.ClassifyService;
import com.zhuiYun.project.api.commoditydetail.entity.Commodity;
import com.zhuiYun.project.common.response.CommonResult;
import com.zhuiYun.project.util.pageUtil.PageRequest;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ClassifyController
 * @Description TODO
 * @Author 韩佳轩
 * @Date 2023/4/6 10:33
 **/
@RestController
@RequestMapping("/commodity/classify/")
@Slf4j
@CrossOrigin
public class ClassifyController {
    @Autowired
    ClassifyService classifyService;
    /**
     * @Author 韩佳轩
     * @Description  全查大分类
     * @Date 2023/4/6 14:44
     * @Return com.zhuiYun.project.common.response.CommonResult
     * @param bigClassify
     */
    @GetMapping("/getBigClassify")
    @ApiOperation(value = "查询大分类方法")
    public CommonResult getBigClassify(BigClassify bigClassify){
        return CommonResult.ok(classifyService.getBigClassify(bigClassify));
    }


   /**
   * @Author 韩佳轩
   * @Description  根据大分类id查小分类
   * @Date 2023/4/6 14:44
   * @Return com.zhuiYun.project.common.response.CommonResult
   * @param classify
   */
   @GetMapping("/getClassify")
   @ApiOperation(value = "查询小分类方法")
   public CommonResult getClassify(Classify classify){
        return CommonResult.ok(classifyService.getClassify(classify));
    }

    /**
    * @Author 韩佳轩
    * @Description 根据小分类查商品列表
    * @Date 2023/4/6 19:56
    * @Return com.zhuiYun.project.common.response.CommonResult
    */
    @GetMapping("/getCommodity")
    @ApiOperation(value = "查询商品列表方法")
    public CommonResult getCommodity(Commodity commodity){
        return CommonResult.ok(classifyService.getComodityList(commodity));
    }


    /**
     * @Author 韩佳轩
     * @Description 根据商品列表查商品详情
     * @Date 2023/4/6 19:56
     * @Return com.zhuiYun.project.common.response.CommonResult
     */
    @GetMapping("/getShopsMain")
    @ApiOperation(value = "商品详情方法")
    public CommonResult getShopsMain(Commodity commodity){
        return CommonResult.ok(classifyService.getShopsMain(commodity));
    }

    /**
    * @Author 韩佳轩
    * @Description 商品详情下的评论全查
    * @Date 2023/4/9 19:29
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param commodityComment
    * @param pageRequest
    */
    @GetMapping("/getShopsMaincomments")
    @ApiOperation(value = "商品详情下的评论全查")
    public CommonResult getShopsMaincomments(CommodityComment commodityComment, PageRequest pageRequest){
        return CommonResult.ok(classifyService.getShopsMaincomments(commodityComment,pageRequest));
    }

    @GetMapping("/getShopsScore")
    @ApiOperation(value = "商品详情下的评论的评分")
    public CommonResult getScore(CommodityComment commodityComment){
        return CommonResult.ok(classifyService.getScore(commodityComment));
    }
}
